$(function() {
	$(document).ready(function() {
		$(".header").load("header_con.html");
		$(".footer").load("footer.html");
		//	轮播图部分
		var mySwiper = new Swiper('.swiper-container', {
			direction: 'horizontal',
			loop: true,
			// 如果需要分页器
			pagination: '.swiper-pagination',
			//循环播放
			autoplay: 3000,
			speed: 300,
		})
		//	 切换每个店铺的商品种类
		$(".carhead").each(function() {
			$(this).find("span").eq(1).mouseenter(function() {
				$(this).parents(".car").find(".line").css("left", "337px");
				$(this).parents(".car").find(".onecar>img").attr("src", "img/index/car2.png");
			})
			$(this).find("span").eq(2).mouseenter(function() {
				$(this).parents(".car").find(".line").css("left", "472px");
				$(this).parents(".car").find(".onecar>img").attr("src", "img/index/hotel2.png")
			})
			$(this).find("span").eq(3).mouseenter(function() {
				$(this).parents(".car").find(".line").css("left", "607px");
				$(this).parents(".car").find(".onecar>img").attr("src", "img/index/shirt2.png")
			})
		})
		//	每一件商品的事件
		$(".onecar").each(function() {
			$(this).mouseenter(function() {
				$(this).find("p:nth-of-type(1)").animate({
					top: "119px"
				}, 50);
			})
			$(this).mouseleave(function() {
				$(this).find("p:nth-of-type(1)").animate({
					top: "260px"
				}, 0);
			})
		})
		//	分类导航
		document.onmousewheel = function() {
//			console.log(document.body.scrollTop || document.documentElement.scrollTop);
			var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
			if(scrollTop >= 680 && scrollTop <= 3800) {
				$(".sort").css("opacity", "1");
			} else {
				$(".sort").css("opacity", "0");
			}
			//头部和底部
			$(".sort div").eq(0).click(function() {
				document.documentElement.scrollTop = 0;
				document.body.scrollTop = 0;
				$(".sort").css("opacity", "0");
			})
			$(".sort div").eq(6).click(function() {
				document.documentElement.scrollTop = 3955;
				document.body.scrollTop = 3955;
				$(".sort").css("opacity", "0");
			})
			//所有楼层
			var a = 0,
				b1, c, d = 40;
			var timer;
			$(".sort div").eq(1).click(function() {
				a = 0;
				b1 = document.body.scrollTop || document.documentElement.scrollTop;
				console.log(b1);
				c = 860 - b1;
				timer = setInterval(function() {
					a++;
					if(a == d) {
						clearInterval(timer);
					}
					document.documentElement.scrollTop = Tween.Cubic.easeIn(a, b1, c, d);
					document.body.scrollTop = Tween.Cubic.easeIn(a, b1, c, d);
				}, 10);
			})
			$(".sort div").eq(2).click(function() {
				a = 0;
				b1 = document.body.scrollTop || document.documentElement.scrollTop;
				console.log(b1);
				c = 1337 - b1;
				timer = setInterval(function() {
					a++;
					if(a == d) {
						clearInterval(timer);
					}
					document.documentElement.scrollTop = Tween.Cubic.easeIn(a, b1, c, d);
					document.body.scrollTop = Tween.Cubic.easeIn(a, b1, c, d);
				}, 10);
			})
			$(".sort div").eq(3).click(function() {
				a = 0;
				b1 = document.body.scrollTop || document.documentElement.scrollTop;
				c = 1957 - b1;
				timer = setInterval(function() {
					a++;
					if(a == d) {
						clearInterval(timer);
					}
					document.documentElement.scrollTop = Tween.Cubic.easeIn(a, b1, c, d);
					document.body.scrollTop = Tween.Cubic.easeIn(a, b1, c, d);
				}, 10);
			})
			$(".sort div").eq(4).click(function() {
				a = 0;
				b1 = document.body.scrollTop || document.documentElement.scrollTop;
				c = 2749 - b1;
				timer = setInterval(function() {
					a++;
					if(a == d) {
						clearInterval(timer);
					}
					document.documentElement.scrollTop = Tween.Cubic.easeIn(a, b1, c, d);
					document.body.scrollTop = Tween.Cubic.easeIn(a, b1, c, d);
				}, 10);
			})
			$(".sort div").eq(5).click(function() {
				a = 0;
				b1 = document.body.scrollTop || document.documentElement.scrollTop;
				c = 3541 - b1;
				timer = setInterval(function() {
					a++;
					if(a == d) {
						clearInterval(timer);
					}
					document.documentElement.scrollTop = Tween.Cubic.easeIn(a, b1, c, d);
					document.body.scrollTop = Tween.Cubic.easeIn(a, b1, c, d);
				}, 10);
			})
		}

	})
})
//商品列表跳转
$(".onecar").click(function() {
	window.location = "M_business.html";
})
$(".brand>div>div").click(function() {
	window.location = "M_choice.html";
})